    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="/static/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
    <link href="/static/css/modification.css" rel="stylesheet" media="screen">

    <script src="/static/bootstrap/js/jquery.js"></script>
    <script src="/static/bootstrap/js/bootstrap.min.js"></script>
    <style type="text/css">
    body {
        padding-top: 0px;
        padding-bottom: 40px;
    }
    .navbar {
        margin-bottom: 20px;
    }
    .navbar .dropdown{
        width:120px;
    }
    .suggest {position: absolute;border:1px solid blue;background-color: #fff;width:210px;margin:0px;padding:5px;line-height: 22px;}
    .suggest div{height:22px;overflow: hidden}

    </style>
    <style type="text/css">
    .bg{display:none;position:fixed;width:100%;height:100%;background:#000;z-index:2;top:0;left:0;opacity:0.7;}
</style>
<h4 style="padding-left:10px;;">库存配置
</h4>

{if isset($list[0]) && !empty($list[0])}
<div class="control-group">
    <div class="control-group">
        <label class="control-label" >闪购原价：</label>
        <div class="controls" style="margin: -31px 10px 10px 66px;">
            <span style="line-height: 35px;">{$flashInfo['cost_price']} 元</span>
        </div>
    </div>
    <div class="controls">
        <table style="width: 80%" border="1">
            <thead>
            <tr>
                <td>商品名称</td>
                <td>规格：数量：价格（元）: 已售数量</td>
                <td>操作</td>
            </tr>
                <tr>
                    <td>{if isset($list[0]['product']['title'])}{$list[0]['product']['title']}{/if}</td>
                    <td>
                        {if isset($list[0]['childGoods']) && !empty($list[0]['childGoods'])}
                            {loop $list[0]['childGoods'] $k2 $v2}
                                {$v2['attrPathName']} : {$v2['stockNum']}件 ：{$v2['saleprice']}元 : {$v2['saleNum']}件<br />
                            {/loop}
                        {/if}
                    </td>
                    <td><a href="javascript:void(0);" id="delLog_{$flashId}" ids="{$flashId}" >删除</a></td>
                </tr>
            </thead>
        </table>
    </div>
</div>
{else}
<!--闪购添加商品START-->
    <form class="form-horizontal" method="POST" action="?c=adminFlashBuy&a=addFlashGoods&flashId={$flashId}"  >
        <div class="control-group">
            <div class="controls">
                <input type="hidden"  name="flashId" value="{$flashId}"/>
                <input type="text" autocomplete="off" id="pcode" value="{if !empty($pcode)}{$pcode}{/if}" name="pcode" placeholder="输入货号" />
                <span></span>
                <input class="btn" type="submit" value="查询" />
            </div>
            <script>
                $('#pcode').on('keyup',function(){
                    var keywords = $(this).val();
                    var _this = $(this);

                    function render(data){
                        if(data.lenth>0) {
                            var arr = [];
                            for (var i = 0; i < data.length; i++) {
                                arr.push('<div did="'+data['id']+'">'+data['name']+'</div>');
                            }
                        }else{
                            container.append('<div class="suggest"><div>无结果</div>')
                        }
                    }
                    $.ajax({
                        dataType: "json",
                        url: '/index.php?c=adminErp&a=searchProduct&keywords='+keywords,
                        success: function(data){
                            $('.suggest').remove();
                            if(data.length > 0){
                                var arr = [];
                                for (var i = 0; i < data.length; i++) {
                                    console.log(i);
                                    arr.push('<div did="' + data[i]['id'] + '">' + data[i]['name'] + '</div>');
                                }
                                $(_this).parent().append('<div class="suggest">'+arr.join('')+'</div>')
                                $('.suggest div').on('click',function(){
                                    $(_this).val($(this).attr('did'));
                                    $(_this).parent().find('span').html($(this).text());
                                    $('.suggest').remove();
                                });
                            }else{
                                $(_this).parent().append('<div class="suggest"><div>无结果</div>')
                            }
                        }
                    });

                });

            </script>
        </div>
    </form>


    {if !empty($productInfo)}
    <form class="form-horizontal"  action="?c=adminFlashBuy&a=ajaxaddFlashGoods"  id="tr_form">
        <div class="control-group">
            <div class="controls">
                <span style="margin: 10px  10px 10px 10px">
                 <img src="{$productInfo['imageUrl']}" style="width: 100px;height: 100px;">
                </span>
                {$productInfo['title']}
            </div>
        </div>

        <div class="control-group">
            <div class="controls">
                <table style="width: 100%" border="1" id="table">
                    <thead>
                    <tr>
                        <td>规格</td>
                        <td>实际库存</td>
                        <td style="display: none"></td>
                        <td>计划数量</td>
                        <td>进货价</td>
                        <td>售价</td>
                    </tr>
                    {if !empty($productInfo['childGoods'])}
                    {loop $productInfo['childGoods'] $k2 $v2}
                    <tr>
                        <td>{$v2['attrPathName']}</td>
                        <td>{$v2['realStockNum']}</td>
                        <td style="display: none"><input type="hidden" name="gid[$k2]" class="gidInput" value="{$v2['gid']}" ></td>
                        <td><input type="text" name="stockIntoCnt[$k2]"  class="stockIntoInput"  placeholder="" value="0"/></td>
                        <td>{$v2['firstCost']}</td>
                        <td><input type="text" name="price[$k2]" class="priceInput"  placeholder="请输入售价" /></td>
                    </tr>
                    {/loop}
                    {/if}

                    </thead>
                </table>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" >闪购原价：</label>
            <div class="controls">
                <span style="line-height: 35px;">{$flashInfo['cost_price']} 元</span>
            </div>
        </div>
        <div class="control-group">
            <div class="controls">
                <input type="hidden" name="flashId" value="{$flashId}"/>
                <input type="hidden" name="pcode_2" value="{$pcode}"/>
                <span class="btn btn-primary" type="button" id="qd">确定</span>
            </div>
        </div>
    </form>
    {/if}
<!--闪购添加商品END-->
{/if}


<script type="text/javascript">
    $(document).on("click",".delimages", function () {
        var _this=$(this),_del = $(this).prev('span');
        _del.remove();
        _this.remove();
    })
    $('#qd').on('click',function(){
        $.ajax({
            type:'POST',
            url:$('#tr_form').attr('action'),
            data:$('#tr_form').serialize(),
            dataType:'json',
            success:function(d){
                if(d.status=='ok'){
                    alert(d.error_msg);
                    window.location.href=d.url;
                }else{
                    alert(d.error_msg);
                }
            }
        })
    })
</script>

<div class="bg" id="bgx"></div>
<div id="dialog" style="position: absolute; z-index: 1003;background-color:white; display: none;" >
    <div  style="margin:50px 100px;">
        <div class="controls">
            <div style="padding-left:20px;">确定操作？</div><br />
            <div style="text-align: center">
                <button class="btn btn-primary" id="ok" ids="">确定</button>
                <button class="btn btn-primary" id="close" >取消</button>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    $("a[id^='delLog_']").on('click',function () {
        var _this = $(this), _ids = _this.attr('ids');
        $("#bgx").show();
        letDivCenter('#dialog');
        $('#ok').attr({ids:_ids, action:'?c=adminFlashBuy&a=ajaxDelFlashGoods'});
    })

    $('#ok').on('click',function(){
        var _this = $(this),ids=_this.attr('ids'), action=_this.attr('action');
        $.ajax({
            type:'POST',
            url:action,
            data:{flashId:ids},
            dataType:'json',
            success:function(d){
                if(d.status=='ok'){
                    alert(d.error_msg);
                    window.location.reload();
                }else{
                    $('#close').click();
                    alert(d.error_msg);
                }
            }
        })
    })
    $('#close').on('click',function(){
        $('#dialog').css('display','none');
        $("#bgx").fadeOut(300);
    })
    function letDivCenter(divName){
        var divObj = $(divName);
        var wWidth = $(document.body).width(),wHeight = $(window).height();
        var divWidth = divObj.width(),divHeight = divObj.height();
        divObj.css({'left':(wWidth-divWidth)/2+$(window).scrollLeft(),'top':(wHeight-divHeight)/2+$(window).scrollTop(),'display':'block'});
        $(window).bind('scroll resize',function(){
            $(divName).css({'left':(wWidth-divWidth)/2+$(window).scrollLeft(),'top':(wHeight-divHeight)/2+$(window).scrollTop()});
        });
    }

    $('.priceInput').change(function(){
        var val = parseFloat($(this).val())
        if(isNaN(val)){
            $(this).val('0')
            return
        }else{
            $(this).val(val)
        }
        var low_price = 99999
        $('.priceInput').each(function(){
            var price = parseFloat($(this).val())
            if(low_price > price){
              low_price = price
            }
        })
        $("#low_price",window.parent.document).text(low_price);
    })

</script>
{template footer}